
<head>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
    <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
    <%@ taglib prefix="security" uri="http://www.springframework.org/security/tags" %>

</head>
<script type="text/javascript">
    var select_id="${question.questionId}";
    var availability = "${question.questionAvailabilityType.code}";
    var status = "${question.questionStatusType.code}";
    $(document).ready(function() { //data_tbody brief
        $("#editquestion").click(function (){
            $("#Msg_lock").hide();
            $("#Msg_retire").hide();
            if (status == "retired"){
                $("#Msg_lock").hide();
                $("#Msg_retire").show();
                return false;
            }
            if (availability=="locked"){
                $("#Msg_retire").hide();
                $("#Msg_lock").show();
                return false;
            }
            if (status == "active" && availability=="open"){
                $("#Msg_lock").hide();
                $("#Msg_retire").hide();
                window.location.href="edit.html?id="+select_id;
            }

        });
        $("#newversionquestion").click(function (){
            $("#Msg_lock").hide();
            $("#Msg_retire").hide();
            if (status == "retired"){
                $("#Msg_lock").hide();
                $("#Msg_retire").show();
                return false;
            }
            if (status == "active"){
                $("#Msg_lock").hide();
                $("#Msg_retire").hide();
                window.location.href="newversion.html?id="+select_id;
            }

        });
        $("#copyquestion").click(function (){
            window.location.href="copy.html?id="+select_id;

        });
        $("#retirequestion").click(function (){
            $("#Msg_lock").hide();
            $("#Msg_retire").hide();
            if (status == "retired"){
                $("#Msg_lock").hide();
                $("#Msg_retire").show();
                return false;
            }
            if (status == "active"){
                $("#Msg_lock").hide();
                $("#Msg_retire").hide();
                window.location.href="retire.html?id="+select_id;
            }
        });
        $("#deletequestion").click(function (){
            $("#Msg_lock").hide();
            $("#Msg_retire").hide();
            if (availability=="locked"){
                $("#Msg_lock").show();
                $("#Msg_retire").hide();
                return false;
            }
            if (status == "retired"){
                $("#Msg_lock").hide();
                $("#Msg_retire").show();
                return false;
            }
            if (confirm("Are you sure you want to delete this Question?")){
                $.post('delete.html', {
                    id: select_id
                },
                function(data) {
                    if (data != ""){
                        if (data.indexOf(":true")>0){
                            data = data.replace(":true","");
                            window.location.href="list.html?checkSearch=list";
                        }
                        $('.message').html(data);
                        return false;
                    }else{
                        $('.message').html("error!");
                    }
                });
            }else{
                $('.message').html("Action cancelled");
            }

        });
    });
    function ShowResponse(){
        var div_radiobutton = document.getElementById("div_radiobutton");
        var div_none = document.getElementById("div_none");
        var div_textarea = document.getElementById("div_textarea");
        var div_checkbox = document.getElementById("div_checkbox");
        var div_string = document.getElementById("div_string");
        var div_float = document.getElementById("div_float");
        var div_date = document.getElementById("div_date");
        var div_custom = document.getElementById("div_custom");
        var div_dynamic = document.getElementById("div_dynamic");
        var div_dropdown = document.getElementById("div_dropdown");
        var div_display = document.getElementById("div_display");
        var TypeName = "${responseName}";
        var div_int = document.getElementById("div_int");
        if (TypeName=="Please Select" || TypeName=="Yes/No" || TypeName=="No/Yes" || TypeName=="Social Security Number" || TypeName==" Phone Number" || TypeName=="Email Address" || TypeName=="US States" ){
            div_custom.style.display="none";
            div_dynamic.style.display="none";
            div_radiobutton.style.display="none";
            div_none.style.display="none";
            div_textarea.style.display="none";
            div_checkbox.style.display="none";
            div_string.style.display="none";
            div_float.style.display="none";
            div_date.style.display="none";
            div_dropdown.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";
        }
        if (TypeName=="Display"){
            	div_display.style.display="";
                div_custom.style.display="none";
                div_dynamic.style.display="none";
                div_radiobutton.style.display="none";
                div_none.style.display="none";
                div_textarea.style.display="none";
                div_checkbox.style.display="none";
                div_string.style.display="none";
                div_float.style.display="none";
                div_date.style.display="none";
                div_dropdown.style.display="none";
                div_int.style.display="none";
            }
        if (TypeName=="Custom"){
            //check exist session response type, if exist then delete it
            div_custom.style.display="";
            div_dynamic.style.display="none";
            div_radiobutton.style.display="none";
            div_none.style.display="none";
            div_textarea.style.display="none";
            div_checkbox.style.display="none";
            div_string.style.display="none";
            div_float.style.display="none";
            div_date.style.display="none";
            div_dropdown.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";
        }
        if (TypeName=="Dynamic"){
            div_dynamic.style.display="";
            div_custom.style.display="none";
            div_radiobutton.style.display="none";
            div_none.style.display="none";
            div_textarea.style.display="none";
            div_checkbox.style.display="none";
            div_string.style.display="none";
            div_float.style.display="none";
            div_date.style.display="none";
            div_dropdown.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";
        }
        //----------
        var uiControlName = "${uiControlName}";
        var dateTypeName = "${dateTypeName}";
        if (uiControlName=="Radio Button"){
            div_radiobutton.style.display="";
            div_none.style.display="none";
            div_textarea.style.display="none";
            div_checkbox.style.display="none";
            div_string.style.display="none";
            div_float.style.display="none";
            div_date.style.display="none";
            div_dropdown.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";

        }
        if (uiControlName=="Dropdown"){
            div_dropdown.style.display="";
            div_radiobutton.style.display="none";
            div_none.style.display="none";
            div_textarea.style.display="none";
            div_checkbox.style.display="none";
            div_string.style.display="none";
            div_float.style.display="none";
            div_date.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";
        }
        if (uiControlName=="Check Box"){
            div_checkbox.style.display="";
            div_none.style.display="none";
            div_textarea.style.display="none";
            div_radiobutton.style.display="none";
            div_string.style.display="none";
            div_float.style.display="none";
            div_date.style.display="none";
            div_dropdown.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";
        }
        if (uiControlName=="Please Select" || TypeName=="Text Box" || TypeName=="Text Area"){
            div_date.style.display="none";
            div_radiobutton.style.display="none";
            div_textarea.style.display="none";
            div_checkbox.style.display="none";
            div_string.style.display="none";
            div_float.style.display="none";
            div_none.style.display="none";
            div_dropdown.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";
        }
        //-----
        if ((uiControlName=="Text Box" && dateTypeName=="Boolean") || (uiControlName=="Text Box" && dateTypeName=="Boolean")){
            div_date.style.display="none";
            div_radiobutton.style.display="none";
            div_textarea.style.display="none";
            div_checkbox.style.display="none";
            div_string.style.display="none";
            div_float.style.display="none";
            div_none.style.display="none";
            div_dropdown.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";
        }
        if ((uiControlName == "Text Box" && dateTypeName=="String") || (uiControlName == "Text Area" && dateTypeName=="Date") ||  (uiControlName == "Text Area" && TypeName=="Float")){
            div_date.style.display="none";
            div_radiobutton.style.display="none";
            div_textarea.style.display="none";
            div_checkbox.style.display="none";
            div_string.style.display="none";
            div_float.style.display="none";
            div_none.style.display="none";
            div_dropdown.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";
        }
        if (uiControlName == "Text Box" && dateTypeName=="Date"){
            div_date.style.display="";
            div_radiobutton.style.display="none";
            div_textarea.style.display="none";
            div_checkbox.style.display="none";
            div_string.style.display="none";
            div_float.style.display="none";
            div_none.style.display="none";
            div_dropdown.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";
        }
        if (uiControlName == "Text Area" && dateTypeName=="String"){
            div_textarea.style.display="";
            div_radiobutton.style.display="none";
            div_date.style.display="none";
            div_checkbox.style.display="none";
            div_string.style.display="none";
            div_float.style.display="none";
            div_none.style.display="none";
            div_dropdown.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";
        }
        if (uiControlName == "Text Box" && dateTypeName=="String"){
            div_string.style.display="";
            div_radiobutton.style.display="none";
            div_textarea.style.display="none";
            div_checkbox.style.display="none";
            div_date.style.display="none";
            div_float.style.display="none";
            div_none.style.display="none";
            div_dropdown.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";
        }
        if (uiControlName == "Text Box" && dateTypeName=="Float"){
            div_float.style.display="";
            div_radiobutton.style.display="none";
            div_date.style.display="none";
            div_checkbox.style.display="none";
            div_string.style.display="none";
            div_textarea.style.display="none";
            div_none.style.display="none";
            div_dropdown.style.display="none";
            div_int.style.display="none";
            div_display.style.display="none";
        }
        if (uiControlName == "Text Box" && dateTypeName=="Integer"){
            div_int.style.display="";
            div_float.style.display="none";
            div_radiobutton.style.display="none";
            div_date.style.display="none";
            div_checkbox.style.display="none";
            div_string.style.display="none";
            div_textarea.style.display="none";
            div_none.style.display="none";
            div_dropdown.style.display="none";
            div_display.style.display="none";
        }

    }
    $("#editquestion").click(function (){
        $.post('checkquestion.html', {
            id: select_id
        },
        function(data) {
            if (data != ""){
                $('.error h3').html(data);
                return false;
            }else{
                window.location.href="edit.html?id=${question.questionId}";
            }
        });

    });
    $("#newversionquestion").click(function (){
        $.post('checkquestion.html', {
            id: select_id
        },
        function(data) {
            if (data != ""){
                $('.error h3').html(data);
                return false;
            }else{
                window.location.href="newversion.html?id=${question.questionId}";
            }
        });
    });
</script>
<body onload="ShowResponse();">
    <!-- Menu -->
    <jsp:include page="menu.jsp" />
    <!--START: Subnav -->
    <div class="sub_nav">
        <ul>
            <li><a href="#"><img src="<%= request.getContextPath()%>/images/menu/sub_general_on.gif" width="114" height="18" alt="gernal" /></a></li>
            <li><a href="whereused.html?id=${question.questionId}"><img src="<%= request.getContextPath()%>/images/menu/sub_where_used_off.gif" width="114" height="18" alt="gernal" /></a></li>
        </ul>
    </div>
    <!--END: Subnav -->
    <!--START: conent -->
    <div class="content2">
        <div class="insider">
            <div class="corners">
                <div class="corners_top"></div>
                <div class="column1">
                    <div class="col_l">
                        <table width="440" border="0" cellspacing="4" class="formlayout_table">
                            <tr>
                                <th width="188"><label><spring:message code="question.id" />:</label></th>
                                <td width="240">${question.refId}</td>
                            </tr>
                            <tr>
                                <th><label><spring:message code="question.version" />:</label></th>
                                <td>${question.version}<br /></td>
                            </tr>
                             <tr>
                                <th><label>Name:</label></th>
                                <td>${question.name}</td>
                            </tr>
                            <tr>
                                <th><label>Vocabulary Name:</label></th>
                                <td>${question.vocabularyname}</td>
                            </tr>
                            <tr>
                                <th><label><spring:message code="question.text" />:</label></th>
                                <td>${question.text}</td>
                            </tr>
                            <tr>
                                <th><label><spring:message code="question.description" />:</label></th>
                                <td>${question.description}</td>
                            </tr>
                            <tr>
                                <th><label><spring:message code="question.helptext" />:</label></th>
                                <td>${question.helpText}</td>
                            </tr>
                            <tr>
                                <th><label><spring:message code="question.responsetype" />:</label></th>
                                <td>
                                ${responseName}</td>
                            </tr>
                        </table>
                    </div>
                    <table width="282" border="0" cellspacing="4" class="formlayout_table fr">
                        <tr>
                            <th width="159"><label><spring:message code="question.siblingid" />:</label></th>
                            <td width="111">${question.sibling.refId}</td>
                        </tr>
                        <tr>
                            <th><label><spring:message code="question.siblingversion" />:</label></th>
                            <td>${question.sibling.version}</td>
                        </tr>
                        <tr>
                            <th><label><spring:message code="question.status" />:</label></th>
                            <td>${question.questionStatusType.code}</td>
                        </tr>
                        <tr>
                            <th><label><spring:message code="question.availability" />:</label></th>
                            <td>${question.questionAvailabilityType.code}</td>
                        </tr>
                        <tr>
                            <th><label><spring:message code="application.lastmodifieddate" />:</label></th>
                            <td>
                                <fmt:formatDate value="${question.modifiedOn}" pattern="dd-MMM-yyyy" />
                            </td>
                        </tr>
                        <tr>
                            <th><label><spring:message code="application.lastmodifiedby" />:</label></th>
                            <td>${question.modifiedBy.username}</td>
                        </tr>
                        <tr>
                            <th><label><spring:message code="question.retiredby" />:</label></th>
                            <td>${question.retiredBy.username}</td>
                        </tr>
                        <tr>
                            <th><label><spring:message code="question.retireddate" />:</label></th>
                            <td>
                                <fmt:formatDate value="${question.retiredOn}" pattern="dd-MMM-yyyy" />
                            </td>
                        </tr>
                        <tr>
                            <th><label><spring:message code="question.retirednotes" />:</label></th>
                            <td>${question.retiredNote}</td>
                        </tr>
                    </table>
                    <div id="div_custom" style="display:none;">
                        <table width="750" border="0" cellspacing="6" class="formlayout_table cb">
                            <tr>
                                <th width="190"><label>UI Control:</label></th>
                                <td width="244">
                                    ${uiControlName}
                                </td>
                                <th width="26"></th>

                                <th width="161"><label>Data Type:</label></th>
                                <td width="110">
                                    ${dateTypeName}
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="div_dynamic" style="display:none;">
                        <table width="750" border="0" cellspacing="6" class="formlayout_table cb">
                            <tr>
                                <th width="190"><label>UI Control:</label></th>
                                <td width="244">
                                    ${uiControlName}
                                </td><th width="26"></th>
                                <th width="161"><label>Data Type:</label></th>
                                <td width="110">
                                    ${dateTypeName}
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="div_none" style="display:none;">

                    </div>
                    <div id="div_checkbox" style="display:none;">
                        <table width="750" border="0" cellspacing="4" class="formlayout_table cb">
                            <tr>
                                <th>&nbsp;</th>
                                <td class="response_type_check"><dl class="edit">
                                        <c:forEach var="lresponseEntity" items="${lresponseEntity}">
                                            <dd><div><strong>${lresponseEntity.label}</strong><em>${lresponseEntity.value}</em></div></dd>

                                        </c:forEach>
                                </dl></td>
                            </tr>
                            <tr>
                                <th><label>Entries:</label></th>
                                <td>${entitys}</td>
                            </tr>
                            <tr>
                                <th width="190"><label>Max Selections:</label></th>
                                <td width="543">${question.maxResponses}</td>
                            </tr>
                        </table>
                    </div>
                    <div id="div_radiobutton" style="display:none;">
                        <table width="750" border="0" cellspacing="4" class="formlayout_table cb">
                            <tr>
                                <th width="190">&nbsp;</th>
                                <td class="response_type"><dl class="edit">
                                        <c:forEach var="lresponseEntity" items="${lresponseEntity}">
                                            <dd><div><strong>${lresponseEntity.label}</strong><em>${lresponseEntity.value}</em></div></dd>
                                        </c:forEach>
                                </dl></td>
                            </tr>

                            <tr>
                                <th><label>Entries:</label></th>
                                <td>${entitys}</td>
                            </tr>
                        </table>
                    </div>
                    <div id="div_dropdown" style="display:none;">
                        <table width="750" border="0" cellspacing="4" class="formlayout_table cb">
                            <tr>
                                <th width="190">&nbsp;</th>
                                <td class="response_type_dropdown"><dl class="edit">
                                        <c:forEach var="lresponseEntity" items="${lresponseEntity}">
                                            <dd><div><strong>${lresponseEntity.label}</strong><em>${lresponseEntity.value}</em></div></dd>
                                        </c:forEach>
                                </dl></td>
                            </tr>
                            <tr>
                                <th><label>Entries:</label></th>
                                <td>${entitys}</td>
                            </tr>
                        </table>
                    </div>
                    <div id="div_textarea" style="display:none;">
                        <table width="750" border="0" cellspacing="4" class="formlayout_table">
                            <tr>
                                <th width="190"><label>Columns:</label></th>
                                <td width="543">${question.width}</td>
                            </tr>
                            <tr>
                                <th><label>Rows:</label></th>
                                <td>${question.rows}</td>
                            </tr>
                            <tr>
                                <th><label>Minimum Chars:</label></th>
                                <td>${question.minResponseValue}</td>
                            </tr>
                            <tr>
                                <th><label>Maximum Chars:</label></th>
                                <td>${question.maxResponseValue}</td>
                            </tr>
                            <tr>
                                <th><label>Edit Mask:</label></th>
                                <td>${mask}
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="div_string" style="display:none;">
                        <table width="750" border="0" cellspacing="4" class="formlayout_table">
                            <tr>
                                    <th><label>Width(in pixels):</label></th>
                                    <td>${question.width}</td>
                                </tr>
                                <tr>
                                    <th><label>Minimum Chars:</label></th>
                                    <td>${question.minResponseValue}</td>
                                </tr>
                                <tr>
                                    <th><label>Maximum Chars:</label></th>
                                    <td>${question.maxResponseValue}</td>
                                </tr>
                            <tr>
                                <th width="190"><label>Units:</label></th>
                                <td width="543">                                   
                                   ${units}
                                </td>
                            </tr>
                            <tr>
                                <th><label>Edit Mask:</label></th>
                                <td>${mask}
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="div_float" style="display:none;">
                        <table width="750" border="0" cellspacing="4" class="formlayout_table">
                            <tr>
                                <th width="190"><label>Minimum Value:</label></th>
                                <td width="543">${question.minResponseValue}</td>
                            </tr>
                            <tr>
                                <th><label>Maximum Value:</label></th>
                                <td>${question.maxResponseValue}</td>
                            </tr>
                            <tr>
                                <th><label>Significant Digits:</label></th>
                                <td>${question.maxResponses}</td>
                            </tr>
                            <tr>
                                <th><label>Units:</label></th>
                                <td>
                                    ${units}
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="div_int" style="display:none;">
                        <table width="750" border="0" cellspacing="4" class="formlayout_table">
                            <tr>
                                <th width="190"><label>Minimum Value:</label></th>
                                <td width="543">${question.minResponseValue}</td>
                            </tr>
                            <tr>
                                <th><label>Maximum Value:</label></th>
                                <td>${question.maxResponseValue}</td>
                            </tr>
                            <tr>
                                <th><label>Units:</label></th>
                                <td>
                                    ${units}
                                </td>
                            </tr>
                        </table>
                    </div>
                    <div id="div_display" style="display:none;" class="cb">
                            <table width="750" border="0" cellspacing="4" class="formlayout_table">
                                <tr>
                                    <th width="190"><label>Display Width:</label></th>
                                    <td width="543">${question.width}</td>
                                </tr>                                                             
                            </table>
                    </div>
                    <div id="div_date" style="display:none;">
                        <table width="750" border="0" cellspacing="4" class="formlayout_table">
                            <tr>
                                <th width="190"><label>Minimum Value:</label></th>
                                <td width="543">${question.minResponseValue}</td>
                            </tr>
                            <tr>
                                <th><label>Maximum Value:</label></th>
                                <td>${question.maxResponseValue}</td>
                            </tr>
                        </table>
                    </div>                    
                </div>

                <ul class="functions1">

                    <li>
                        <a href="list.html?checkSearch=list">
                            <img width="122" height="23" class="btn" src="<%= request.getContextPath()%>/images/btn/functions1/back_to_results.gif"/>
                        </a>

                    </li>
                    <security:authorize ifAnyGranted="ROLE_PORTAL_USER, ROLE_AUTHOR">
                        <c:if test="${question.questionStatusType.code=='active' && question.questionAvailabilityType.code=='open'}">
                            <li><a href="#" id="newversionquestion"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_new_version.gif" width="122" height="23" class="btn" /></a></li>
                            <li><a href="#" id="editquestion"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_edit.gif" width="122" height="23" class="btn" /></a></li>
                            <li><a href="#" id="deletequestion"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_delete.gif" alt="" width="122" height="23" class="btn" /></a></li>
                        </c:if>
                        <c:if test="${question.questionStatusType.code=='retired'}">
                            <li><a href="#"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_new_version_tint.gif" width="122" height="23"/></a></li>
                            <li><a href="#"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_edit_tint.gif" width="122" height="23"/></a></li>
                            <li><a href="#"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_delete_tint.gif" alt="" width="122" height="23"/></a></li>
                        </c:if>
                        <c:if test="${question.questionAvailabilityType.code=='locked'}">
                            <li><a href="#" id="newversionquestion"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_new_version.gif" width="122" height="23" class="btn" /></a></li>
                            <li><a href="#"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_edit_tint.gif" width="122" height="23"/></a></li>
                            <li><a href="#"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_delete_tint.gif" alt="" width="122" height="23"/></a></li>
                        </c:if>
                        <li><a href="#" id="copyquestion"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_copy.gif" alt="" width="122" height="23" class="btn" /></a></li>
                    </security:authorize>
                    <security:authorize ifAnyGranted="ROLE_PORTAL_USER, ROLE_REVIEWER">
                        <c:if test="${question.questionStatusType.code=='active' && question.questionAvailabilityType.code=='open'}">
                            <li><a href="#" id="retirequestion"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_retire.gif" alt="" width="122" height="23" class="btn" /></a></li>
                        </c:if>
                        <c:if test="${question.questionStatusType.code=='retired'}">
                            <li><a href="#"><img src="<%= request.getContextPath()%>/images/btn/functions1/btn_retire_tint.gif" alt="" width="122" height="23"/></a></li>
                        </c:if>
                    </security:authorize>
                </ul>

                <div class="corners_bottom"></div>
            </div>
            <div class="message">
                ${questionmessage}
                <style> p { margin:0px }</style>
                <font color="red">
                    <p id="Msg_retire" style="display:none;">${Msg_retire}</p>
                    <p id="Msg_lock" style="display:none;">${Msg_lock}</p>
                </font>
            </div>
        </div>
    </div>
    <!--END: conent -->
</body>
